import { mapState } from 'vuex'
import store from '@/store'

let storeKey = []
try {
  storeKey = store.state ? Object.keys(store.state) : []
} catch (e) {
  //
}
export default {
  created() {
    this.$vuex = (name, value) => {
      const _store = store

      if ([null, undefined].includes(value)) {
        return _store.state[name]
      } else {
        _store.commit('shortcutStore', {
          name,
          value
        })
      }
    }
    this.$store = store
  },
  computed: {
    ...mapState(storeKey)
  }
}
